package com.qdu.servlet;

import com.qdu.entity.ActiComment;
import com.qdu.entity.Activity;
import com.qdu.entity.Log;
import com.qdu.service.ActivCommentService;
import com.qdu.service.ActivityService;
import com.qdu.service.impl.LogServiceImpl;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *处理全部活动jsp页面和查询活动jsp页面的单个活动超链接请求
 * 前半部分是获得单个活动页面的信息
 * 后半部分是获得活动评论的信息。
 * @author 19645
 */
@WebServlet("/gmis")
public class ActivInfoServlet extends HttpServlet{

    ActivityService activityService=new ActivityService();
    ActivCommentService comment=new ActivCommentService();
    LogServiceImpl getLog=new LogServiceImpl();
    
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String activityId = req.getParameter("activityId");
        
        //前半部分获得活动详细信息
        Activity activity=activityService.findActivityById(activityId);
        req.setAttribute("activityInfo", activity);
        
        //后半部分获得活动的评论
        List<ActiComment> avticomment=comment.findComment(activityId);
        List<Log> log =getLog.getAllLog();
        
        req.setAttribute("comment", avticomment);
        req.setAttribute("log",log);
        req.getRequestDispatcher("/ActivityInfo.jsp").forward(req, resp);
        
        
        
        
    }
    
}
